package org.paradise.dms.services.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.paradise.dms.dao.impl.MessageOutDaoImpl;
import org.paradise.dms.pojo.MessageOut;
import org.paradise.dms.services.MessageOutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * Description: MessageOutService.java
 * 
 * @version 李韦
 */

@Service
public class MessageOutServiceImpl implements MessageOutService{
	private static Logger log = Logger.getLogger(MessageOutServiceImpl.class);

	@Autowired
	private MessageOutDaoImpl messageOutDaoImpl = new MessageOutDaoImpl();


	/** 
	 * Description: 插入一条发件记录
	 * @param message
	 * @return
	 */
	public boolean insertMessage (MessageOut message){		
		try {
			this.messageOutDaoImpl.insertMessage(message);
			return true;
		} catch (Exception e) {
			log.error("插入发件记录时出错!!");
			e.printStackTrace();
			return false;
		}
	}
	
	/** 
	 * Description: 删除一条发件记录
	 * @param message
	 * @return
	 */
	public String deleteMessage (final long id){
		try {
			return this.messageOutDaoImpl.deleteMessage(id);
		} catch (Exception e) {
			log.error("删除发件记录时出错!!");
			e.printStackTrace();
			return null;
		}
	}
	
	/**
	 * 
	 * Description: 列出发件箱的所有信息 
	 * @param  
	 * @return
	 */
	public List<MessageOut> listAllMessageOut(){
		try {
			return this.messageOutDaoImpl.listAllMessageOut();
		} catch (Exception e) {
			log.error(" 列出发件箱的所有信息时出错!!");
			e.printStackTrace();
			return null;
		}
	}
	
	/**
	 * Description: 返回发件箱总条数
	 * @return
	 */
	public int getMessageOutRows(){
		try {
			return this.messageOutDaoImpl.getMessageOutRows();
		} catch (Exception e) {
			log.error(" 返回发件箱总条数时出错!!");
			e.printStackTrace();
			return 0;
		}
	}
	

	/**
	 * Description: 返回发件箱成功的总条数
	 * @return
	 */
	public int getMessageOutSuccessRows(){
		try {
			return this.messageOutDaoImpl.getMessageOutSuccessRows();
		} catch (Exception e) {
			log.error(" 返回发件箱成功总条数时出错!!");
			e.printStackTrace();
			return 0;
		}
	}
	@SuppressWarnings("unchecked")
	public List getMessageList(int pageSize, int startRow) {
		try {
			return this.messageOutDaoImpl.getMessageList(pageSize, startRow);
		} catch (Exception e) {
			log.error(" 返回发件箱列表时出错!!");
			e.printStackTrace();
			return null;
		} 
	}


}